import request from '@/utils/request'
import { exportMethod } from '@/utils/utils'
import { CHECC_API_CMS } from '@/constants/proxy'

const insertContract = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-management/insert`, params)
}
const updateContract = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-management/update`, params)
}
const getContractList = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-management/listPage?current=${params.current}&size=${params.size}`, params)
}
const getChangeList = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-change/listliuchengPage?current=${params.current}&size=${params.size}`, params)
}
const examineChange = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-change/updateStatus`, params)
}
const changeContractSave = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-change/insertliucheng`, params)
}
const changeContractSubmit = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-change/update`, params)
}
const getDetailById = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-change/getDetailById`, params)
}
const openContractStatus = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-management/openStatus`, params)
}
const closeContractStatus = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-management/closeStatus`, params)
}
//批量导出合同数据
const exportContractList = (data: any) => {
  const params = {
    method: 'post',
    url: CHECC_API_CMS + '/xmzx/htgl/contract-management/export',
    data: data,
    fileName: '合同数据表格',
  }
  return exportMethod(params)
}
//批量导出合同变更数据
const exportContractChangeList = (data: any) => {
  const params = {
    method: 'post',
    url: CHECC_API_CMS + '/xmzx/htgl/contract-change/export',
    data: data,
    fileName: '合同变更数据表格',
  }
  return exportMethod(params)
}
const delBatchChange = (params: any = {}) => {
  return request.post(CHECC_API_CMS + `/xmzx/htgl/contract-change/delBatchChange`, params)
}

export {
  getContractList,
  getChangeList,
  examineChange,
  changeContractSave,
  changeContractSubmit,
  getDetailById,
  insertContract,
  updateContract,
  openContractStatus,
  closeContractStatus,
  exportContractList,
  exportContractChangeList,
  delBatchChange
}
